#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
void move(int* arr, int n, int m)
{
	int i = 0; int j = 0;
	for (i = 0; i < m; i++)
	{
		int tmp = arr[n - 1];
		for (j = n - 1; j >= 1; j--)
		{
			arr[j] = arr[j - 1];
		}
		arr[0] = tmp;
	}
	
}
int main()//1 2 3 4 5 6 7
//          6 7 1 2 3 4 5
{
	int m, n; int arr[100];
	while (scanf("%d%d", &n, &m) == 2)
	{
		int i = 0;
		for (i = 0; i < n; i++)
		{
			scanf("%d", &arr[i]);
		}
		move(arr, n, m);
		for (i = 0; i < n; i++)
		{
			printf("%d ", arr[i]);
		}
		printf("\n");
	}


	return 0;
}